<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>Coverage for c:\program files\python26\lib\weakref</title>
<link rel='stylesheet' href='style.css' type='text/css'>
<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
<script type='text/javascript'>
function toggle_lines(btn, cls) {
    var btn = $(btn);
    var hide = "hide_"+cls;
    if (btn.hasClass(hide)) {
        $("#source ."+cls).removeClass(hide);
        btn.removeClass(hide);
    }
    else {
        $("#source ."+cls).addClass(hide);
        btn.addClass(hide);
    }
}
</script>
</head>
<body>
<div id='header'>
    <div class='content'>
        <h1>Coverage for <b>c:\program files\python26\lib\weakref</b> :
            <span class='pc_cov'>19%</span>
        </h1>
        <h2 class='stats'>
            211 statements
            <span class='run hide_run' onclick='toggle_lines(this, "run")'>55 run</span>
            <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
            <span class='mis' onclick='toggle_lines(this, "mis")'>156 missing</span>
            
                <span class='par run hide_run' onclick='toggle_lines(this, "par")'>0 partial</span>
            
        </h2>
    </div>
</div>

<div id='source'>
<table cellspacing='0' cellpadding='0'>
<tr>
<td class='linenos' valign='top'>
<p class='pln'>1</p>
<p class='pln'>2</p>
<p class='pln'>3</p>
<p class='pln'>4</p>
<p class='pln'>5</p>
<p class='pln'>6</p>
<p class='pln'>7</p>
<p class='pln'>8</p>
<p class='pln'>9</p>
<p class='pln'>10</p>
<p class='pln'>11</p>
<p class='stm run hide_run'>12</p>
<p class='pln'>13</p>
<p class='stm run hide_run'>14</p>
<p class='pln'>15</p>
<p class='pln'>16</p>
<p class='pln'>17</p>
<p class='pln'>18</p>
<p class='pln'>19</p>
<p class='pln'>20</p>
<p class='pln'>21</p>
<p class='pln'>22</p>
<p class='stm run hide_run'>23</p>
<p class='pln'>24</p>
<p class='pln'>25</p>
<p class='stm run hide_run'>26</p>
<p class='pln'>27</p>
<p class='stm run hide_run'>28</p>
<p class='pln'>29</p>
<p class='pln'>30</p>
<p class='pln'>31</p>
<p class='pln'>32</p>
<p class='stm run hide_run'>33</p>
<p class='pln'>34</p>
<p class='pln'>35</p>
<p class='pln'>36</p>
<p class='pln'>37</p>
<p class='pln'>38</p>
<p class='pln'>39</p>
<p class='pln'>40</p>
<p class='pln'>41</p>
<p class='pln'>42</p>
<p class='pln'>43</p>
<p class='pln'>44</p>
<p class='stm run hide_run'>45</p>
<p class='stm run hide_run'>46</p>
<p class='stm mis'>47</p>
<p class='stm mis'>48</p>
<p class='stm mis'>49</p>
<p class='stm run hide_run'>50</p>
<p class='stm run hide_run'>51</p>
<p class='pln'>52</p>
<p class='stm run hide_run'>53</p>
<p class='stm mis'>54</p>
<p class='stm mis'>55</p>
<p class='stm mis'>56</p>
<p class='pln'>57</p>
<p class='stm mis'>58</p>
<p class='pln'>59</p>
<p class='stm run hide_run'>60</p>
<p class='stm mis'>61</p>
<p class='stm mis'>62</p>
<p class='stm mis'>63</p>
<p class='stm mis'>64</p>
<p class='stm mis'>65</p>
<p class='pln'>66</p>
<p class='stm run hide_run'>67</p>
<p class='stm mis'>68</p>
<p class='stm mis'>69</p>
<p class='stm mis'>70</p>
<p class='stm mis'>71</p>
<p class='stm mis'>72</p>
<p class='pln'>73</p>
<p class='stm run hide_run'>74</p>
<p class='stm mis'>75</p>
<p class='pln'>76</p>
<p class='stm run hide_run'>77</p>
<p class='stm mis'>78</p>
<p class='pln'>79</p>
<p class='stm run hide_run'>80</p>
<p class='stm mis'>81</p>
<p class='stm mis'>82</p>
<p class='stm mis'>83</p>
<p class='stm mis'>84</p>
<p class='stm mis'>85</p>
<p class='stm mis'>86</p>
<p class='pln'>87</p>
<p class='stm run hide_run'>88</p>
<p class='stm mis'>89</p>
<p class='stm mis'>90</p>
<p class='stm mis'>91</p>
<p class='stm mis'>92</p>
<p class='pln'>93</p>
<p class='stm mis'>94</p>
<p class='stm mis'>95</p>
<p class='pln'>96</p>
<p class='stm mis'>97</p>
<p class='pln'>98</p>
<p class='stm mis'>99</p>
<p class='pln'>100</p>
<p class='stm run hide_run'>101</p>
<p class='stm mis'>102</p>
<p class='stm mis'>103</p>
<p class='stm mis'>104</p>
<p class='stm mis'>105</p>
<p class='stm mis'>106</p>
<p class='stm mis'>107</p>
<p class='pln'>108</p>
<p class='stm run hide_run'>109</p>
<p class='stm mis'>110</p>
<p class='stm mis'>111</p>
<p class='stm mis'>112</p>
<p class='stm mis'>113</p>
<p class='pln'>114</p>
<p class='stm run hide_run'>115</p>
<p class='stm mis'>116</p>
<p class='pln'>117</p>
<p class='stm run hide_run'>118</p>
<p class='stm mis'>119</p>
<p class='pln'>120</p>
<p class='stm run hide_run'>121</p>
<p class='pln'>122</p>
<p class='pln'>123</p>
<p class='pln'>124</p>
<p class='pln'>125</p>
<p class='pln'>126</p>
<p class='pln'>127</p>
<p class='pln'>128</p>
<p class='pln'>129</p>
<p class='pln'>130</p>
<p class='stm mis'>131</p>
<p class='pln'>132</p>
<p class='stm run hide_run'>133</p>
<p class='stm mis'>134</p>
<p class='stm mis'>135</p>
<p class='stm mis'>136</p>
<p class='stm mis'>137</p>
<p class='pln'>138</p>
<p class='stm run hide_run'>139</p>
<p class='stm mis'>140</p>
<p class='stm mis'>141</p>
<p class='stm mis'>142</p>
<p class='stm mis'>143</p>
<p class='stm mis'>144</p>
<p class='pln'>145</p>
<p class='stm run hide_run'>146</p>
<p class='stm mis'>147</p>
<p class='stm mis'>148</p>
<p class='stm mis'>149</p>
<p class='stm mis'>150</p>
<p class='stm mis'>151</p>
<p class='stm mis'>152</p>
<p class='stm mis'>153</p>
<p class='stm mis'>154</p>
<p class='pln'>155</p>
<p class='stm mis'>156</p>
<p class='pln'>157</p>
<p class='stm run hide_run'>158</p>
<p class='stm mis'>159</p>
<p class='stm mis'>160</p>
<p class='stm mis'>161</p>
<p class='stm mis'>162</p>
<p class='stm mis'>163</p>
<p class='pln'>164</p>
<p class='stm mis'>165</p>
<p class='pln'>166</p>
<p class='stm run hide_run'>167</p>
<p class='stm mis'>168</p>
<p class='stm mis'>169</p>
<p class='stm mis'>170</p>
<p class='stm mis'>171</p>
<p class='stm mis'>172</p>
<p class='stm mis'>173</p>
<p class='stm mis'>174</p>
<p class='stm mis'>175</p>
<p class='pln'>176</p>
<p class='stm run hide_run'>177</p>
<p class='pln'>178</p>
<p class='pln'>179</p>
<p class='pln'>180</p>
<p class='pln'>181</p>
<p class='pln'>182</p>
<p class='pln'>183</p>
<p class='pln'>184</p>
<p class='pln'>185</p>
<p class='pln'>186</p>
<p class='stm mis'>187</p>
<p class='pln'>188</p>
<p class='stm run hide_run'>189</p>
<p class='stm mis'>190</p>
<p class='stm mis'>191</p>
<p class='stm mis'>192</p>
<p class='stm mis'>193</p>
<p class='stm mis'>194</p>
<p class='stm mis'>195</p>
<p class='pln'>196</p>
<p class='pln'>197</p>
<p class='stm run hide_run'>198</p>
<p class='pln'>199</p>
<p class='pln'>200</p>
<p class='pln'>201</p>
<p class='pln'>202</p>
<p class='pln'>203</p>
<p class='pln'>204</p>
<p class='pln'>205</p>
<p class='pln'>206</p>
<p class='pln'>207</p>
<p class='stm run hide_run'>208</p>
<p class='pln'>209</p>
<p class='stm run hide_run'>210</p>
<p class='stm mis'>211</p>
<p class='stm mis'>212</p>
<p class='stm mis'>213</p>
<p class='pln'>214</p>
<p class='stm run hide_run'>215</p>
<p class='stm mis'>216</p>
<p class='pln'>217</p>
<p class='pln'>218</p>
<p class='stm run hide_run'>219</p>
<p class='pln'>220</p>
<p class='pln'>221</p>
<p class='pln'>222</p>
<p class='pln'>223</p>
<p class='pln'>224</p>
<p class='pln'>225</p>
<p class='pln'>226</p>
<p class='pln'>227</p>
<p class='pln'>228</p>
<p class='pln'>229</p>
<p class='stm run hide_run'>230</p>
<p class='stm mis'>231</p>
<p class='stm mis'>232</p>
<p class='stm mis'>233</p>
<p class='stm mis'>234</p>
<p class='stm mis'>235</p>
<p class='stm mis'>236</p>
<p class='stm mis'>237</p>
<p class='pln'>238</p>
<p class='stm run hide_run'>239</p>
<p class='stm mis'>240</p>
<p class='pln'>241</p>
<p class='stm run hide_run'>242</p>
<p class='stm mis'>243</p>
<p class='pln'>244</p>
<p class='stm run hide_run'>245</p>
<p class='stm mis'>246</p>
<p class='pln'>247</p>
<p class='stm run hide_run'>248</p>
<p class='stm mis'>249</p>
<p class='pln'>250</p>
<p class='stm run hide_run'>251</p>
<p class='stm mis'>252</p>
<p class='stm mis'>253</p>
<p class='stm mis'>254</p>
<p class='stm mis'>255</p>
<p class='stm mis'>256</p>
<p class='stm mis'>257</p>
<p class='pln'>258</p>
<p class='stm run hide_run'>259</p>
<p class='stm mis'>260</p>
<p class='pln'>261</p>
<p class='stm run hide_run'>262</p>
<p class='stm mis'>263</p>
<p class='stm mis'>264</p>
<p class='stm mis'>265</p>
<p class='stm mis'>266</p>
<p class='stm mis'>267</p>
<p class='pln'>268</p>
<p class='stm run hide_run'>269</p>
<p class='stm mis'>270</p>
<p class='stm mis'>271</p>
<p class='stm mis'>272</p>
<p class='stm mis'>273</p>
<p class='stm mis'>274</p>
<p class='pln'>275</p>
<p class='stm run hide_run'>276</p>
<p class='stm mis'>277</p>
<p class='stm mis'>278</p>
<p class='stm mis'>279</p>
<p class='stm mis'>280</p>
<p class='stm mis'>281</p>
<p class='stm mis'>282</p>
<p class='pln'>283</p>
<p class='stm run hide_run'>284</p>
<p class='stm mis'>285</p>
<p class='stm mis'>286</p>
<p class='stm mis'>287</p>
<p class='stm mis'>288</p>
<p class='pln'>289</p>
<p class='stm run hide_run'>290</p>
<p class='pln'>291</p>
<p class='pln'>292</p>
<p class='pln'>293</p>
<p class='pln'>294</p>
<p class='pln'>295</p>
<p class='pln'>296</p>
<p class='pln'>297</p>
<p class='pln'>298</p>
<p class='pln'>299</p>
<p class='stm mis'>300</p>
<p class='pln'>301</p>
<p class='stm run hide_run'>302</p>
<p class='stm mis'>303</p>
<p class='stm mis'>304</p>
<p class='stm mis'>305</p>
<p class='stm mis'>306</p>
<p class='pln'>307</p>
<p class='stm run hide_run'>308</p>
<p class='stm mis'>309</p>
<p class='pln'>310</p>
<p class='stm run hide_run'>311</p>
<p class='stm mis'>312</p>
<p class='pln'>313</p>
<p class='stm run hide_run'>314</p>
<p class='pln'>315</p>
<p class='pln'>316</p>
<p class='pln'>317</p>
<p class='pln'>318</p>
<p class='pln'>319</p>
<p class='pln'>320</p>
<p class='pln'>321</p>
<p class='pln'>322</p>
<p class='pln'>323</p>
<p class='stm mis'>324</p>
<p class='pln'>325</p>
<p class='stm run hide_run'>326</p>
<p class='stm mis'>327</p>
<p class='stm mis'>328</p>
<p class='stm mis'>329</p>
<p class='stm mis'>330</p>
<p class='stm mis'>331</p>
<p class='stm mis'>332</p>
<p class='pln'>333</p>
<p class='stm run hide_run'>334</p>
<p class='stm mis'>335</p>
<p class='stm mis'>336</p>
<p class='stm mis'>337</p>
<p class='stm mis'>338</p>
<p class='stm mis'>339</p>
<p class='pln'>340</p>
<p class='stm run hide_run'>341</p>
<p class='stm mis'>342</p>
<p class='pln'>343</p>
<p class='stm run hide_run'>344</p>
<p class='stm mis'>345</p>
<p class='pln'>346</p>
<p class='stm run hide_run'>347</p>
<p class='stm mis'>348</p>
<p class='stm mis'>349</p>
<p class='stm mis'>350</p>
<p class='stm mis'>351</p>
<p class='stm mis'>352</p>
<p class='stm mis'>353</p>
<p class='stm mis'>354</p>
<p class='stm mis'>355</p>
    
</td>
<td class='text' valign='top'>
<p class='pln'><span class='str'>&quot;&quot;&quot;Weak reference support for Python.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>This module is an implementation of PEP 205:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>http://www.python.org/dev/peps/pep-0205/</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Naming convention: Variables named &quot;wr&quot; are weak reference objects;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># they are called this instead of &quot;ref&quot; to avoid name collisions with</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># the module-global ref() function imported from _weakref.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>import</span> <span class='nam'>UserDict</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>from</span> <span class='nam'>_weakref</span> <span class='key'>import</span> <span class='op'>(</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp;&nbsp; <span class='nam'>getweakrefcount</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp;&nbsp; <span class='nam'>getweakrefs</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp;&nbsp; <span class='nam'>ref</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp;&nbsp; <span class='nam'>proxy</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp;&nbsp; <span class='nam'>CallableProxyType</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp;&nbsp; <span class='nam'>ProxyType</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp;&nbsp; <span class='nam'>ReferenceType</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>from</span> <span class='nam'>exceptions</span> <span class='key'>import</span> <span class='nam'>ReferenceError</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>ProxyTypes</span> <span class='op'>=</span> <span class='op'>(</span><span class='nam'>ProxyType</span><span class='op'>,</span> <span class='nam'>CallableProxyType</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>__all__</span> <span class='op'>=</span> <span class='op'>[</span><span class='str'>&quot;ref&quot;</span><span class='op'>,</span> <span class='str'>&quot;proxy&quot;</span><span class='op'>,</span> <span class='str'>&quot;getweakrefcount&quot;</span><span class='op'>,</span> <span class='str'>&quot;getweakrefs&quot;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='str'>&quot;WeakKeyDictionary&quot;</span><span class='op'>,</span> <span class='str'>&quot;ReferenceError&quot;</span><span class='op'>,</span> <span class='str'>&quot;ReferenceType&quot;</span><span class='op'>,</span> <span class='str'>&quot;ProxyType&quot;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='str'>&quot;CallableProxyType&quot;</span><span class='op'>,</span> <span class='str'>&quot;ProxyTypes&quot;</span><span class='op'>,</span> <span class='str'>&quot;WeakValueDictionary&quot;</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>WeakValueDictionary</span><span class='op'>(</span><span class='nam'>UserDict</span><span class='op'>.</span><span class='nam'>UserDict</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;Mapping class that references values weakly.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Entries in the dictionary will be discarded when no strong</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; reference to the value exists anymore</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># We inherit the constructor without worrying about the input</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># dictionary; since it uses our .update() method, we get the right</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># checks (if the other dictionary is a WeakValueDictionary,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># objects are unwrapped on the way out, and we always wrap on the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># way in).</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kw</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>remove</span><span class='op'>(</span><span class='nam'>wr</span><span class='op'>,</span> <span class='nam'>selfref</span><span class='op'>=</span><span class='nam'>ref</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span> <span class='op'>=</span> <span class='nam'>selfref</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>del</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>wr</span><span class='op'>.</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_remove</span> <span class='op'>=</span> <span class='nam'>remove</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>UserDict</span><span class='op'>.</span><span class='nam'>UserDict</span><span class='op'>.</span><span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kw</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__getitem__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>o</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>KeyError</span><span class='op'>,</span> <span class='nam'>key</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>o</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__contains__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>KeyError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>False</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>o</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>has_key</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>KeyError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>False</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>o</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__repr__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='str'>&quot;&lt;WeakValueDictionary at %s&gt;&quot;</span> <span class='op'>%</span> <span class='nam'>id</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__setitem__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>value</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>KeyedRef</span><span class='op'>(</span><span class='nam'>value</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_remove</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>copy</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>new</span> <span class='op'>=</span> <span class='nam'>WeakValueDictionary</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>wr</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>items</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>wr</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>o</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>new</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>o</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>new</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>get</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>default</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>wr</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>KeyError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>default</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>wr</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>o</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># This should only happen</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>default</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>o</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>items</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>L</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>wr</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>items</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>wr</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>o</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>L</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>,</span> <span class='nam'>o</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>L</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>iteritems</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>wr</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>itervalues</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>value</span> <span class='op'>=</span> <span class='nam'>wr</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>value</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>yield</span> <span class='nam'>wr</span><span class='op'>.</span><span class='nam'>key</span><span class='op'>,</span> <span class='nam'>value</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>iterkeys</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>iterkeys</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__iter__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>iterkeys</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>itervaluerefs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;Return an iterator that yields the weak references to the values.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; The references are not guaranteed to be &#39;live&#39; at the time</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; they are used, so the result of calling the references needs</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; to be checked before being used.&nbsp; This can be used to avoid</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; creating references that will cause the garbage collector to</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; keep the values around longer than needed.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>itervalues</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>itervalues</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>wr</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>itervalues</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>obj</span> <span class='op'>=</span> <span class='nam'>wr</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>obj</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>yield</span> <span class='nam'>obj</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>popitem</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>while</span> <span class='num'>1</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>wr</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>popitem</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>wr</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>o</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>o</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>pop</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>pop</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>)</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>KeyError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>args</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>o</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>KeyError</span><span class='op'>,</span> <span class='nam'>key</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>o</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>setdefault</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>default</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>wr</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>KeyError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>KeyedRef</span><span class='op'>(</span><span class='nam'>default</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_remove</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>default</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>wr</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>update</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>dict</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>d</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>dict</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>,</span> <span class='str'>&quot;items&quot;</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>dict</span> <span class='op'>=</span> <span class='nam'>type</span><span class='op'>(</span><span class='op'>{</span><span class='op'>}</span><span class='op'>)</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>o</span> <span class='key'>in</span> <span class='nam'>dict</span><span class='op'>.</span><span class='nam'>items</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>d</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>KeyedRef</span><span class='op'>(</span><span class='nam'>o</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_remove</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>valuerefs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;Return a list of weak references to the values.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; The references are not guaranteed to be &#39;live&#39; at the time</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; they are used, so the result of calling the references needs</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; to be checked before being used.&nbsp; This can be used to avoid</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; creating references that will cause the garbage collector to</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; keep the values around longer than needed.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>values</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>values</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>L</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>wr</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>values</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>wr</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>o</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>L</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='nam'>o</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>L</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>KeyedRef</span><span class='op'>(</span><span class='nam'>ref</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;Specialized reference that includes a key corresponding to the value.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; This is used in the WeakValueDictionary to avoid having to create</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; a function object for each key stored in the mapping.&nbsp; A shared</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; callback object can use the &#39;key&#39; attribute of a KeyedRef instead</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; of getting a reference to the key from an enclosing scope.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='nam'>__slots__</span> <span class='op'>=</span> <span class='str'>&quot;key&quot;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__new__</span><span class='op'>(</span><span class='nam'>type</span><span class='op'>,</span> <span class='nam'>ob</span><span class='op'>,</span> <span class='nam'>callback</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span> <span class='op'>=</span> <span class='nam'>ref</span><span class='op'>.</span><span class='nam'>__new__</span><span class='op'>(</span><span class='nam'>type</span><span class='op'>,</span> <span class='nam'>ob</span><span class='op'>,</span> <span class='nam'>callback</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>key</span> <span class='op'>=</span> <span class='nam'>key</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>ob</span><span class='op'>,</span> <span class='nam'>callback</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>super</span><span class='op'>(</span><span class='nam'>KeyedRef</span><span class='op'>,</span>&nbsp; <span class='nam'>self</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>ob</span><span class='op'>,</span> <span class='nam'>callback</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>WeakKeyDictionary</span><span class='op'>(</span><span class='nam'>UserDict</span><span class='op'>.</span><span class='nam'>UserDict</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot; Mapping class that references keys weakly.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Entries in the dictionary will be discarded when there is no</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; longer a strong reference to the key. This can be used to</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; associate additional data with an object owned by other parts of</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; an application without adding attributes to those objects. This</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; can be especially useful with objects that override attribute</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; accesses.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>dict</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span> <span class='op'>=</span> <span class='op'>{</span><span class='op'>}</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>remove</span><span class='op'>(</span><span class='nam'>k</span><span class='op'>,</span> <span class='nam'>selfref</span><span class='op'>=</span><span class='nam'>ref</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span> <span class='op'>=</span> <span class='nam'>selfref</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>del</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>k</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_remove</span> <span class='op'>=</span> <span class='nam'>remove</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>dict</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__delitem__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>del</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>ref</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>)</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__getitem__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>ref</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>)</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__repr__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='str'>&quot;&lt;WeakKeyDictionary at %s&gt;&quot;</span> <span class='op'>%</span> <span class='nam'>id</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__setitem__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>value</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>ref</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_remove</span><span class='op'>)</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>value</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>copy</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>new</span> <span class='op'>=</span> <span class='nam'>WeakKeyDictionary</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>value</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>items</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>key</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>o</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>new</span><span class='op'>[</span><span class='nam'>o</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>value</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>new</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>get</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>default</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>get</span><span class='op'>(</span><span class='nam'>ref</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>)</span><span class='op'>,</span><span class='nam'>default</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>has_key</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>wr</span> <span class='op'>=</span> <span class='nam'>ref</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>TypeError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='num'>0</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>wr</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__contains__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>wr</span> <span class='op'>=</span> <span class='nam'>ref</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>TypeError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='num'>0</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>wr</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>items</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>L</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>value</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>items</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>key</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>o</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>L</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='op'>(</span><span class='nam'>o</span><span class='op'>,</span> <span class='nam'>value</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>L</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>iteritems</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>wr</span><span class='op'>,</span> <span class='nam'>value</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>iteritems</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>key</span> <span class='op'>=</span> <span class='nam'>wr</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>key</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>yield</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>value</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>iterkeyrefs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;Return an iterator that yields the weak references to the keys.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; The references are not guaranteed to be &#39;live&#39; at the time</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; they are used, so the result of calling the references needs</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; to be checked before being used.&nbsp; This can be used to avoid</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; creating references that will cause the garbage collector to</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; keep the keys around longer than needed.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>iterkeys</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>iterkeys</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>wr</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>iterkeys</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>obj</span> <span class='op'>=</span> <span class='nam'>wr</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>obj</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>yield</span> <span class='nam'>obj</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__iter__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>iterkeys</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>itervalues</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>itervalues</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>keyrefs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;Return a list of weak references to the keys.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; The references are not guaranteed to be &#39;live&#39; at the time</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; they are used, so the result of calling the references needs</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; to be checked before being used.&nbsp; This can be used to avoid</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; creating references that will cause the garbage collector to</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; keep the keys around longer than needed.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>keys</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>keys</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>L</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>wr</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>keys</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>wr</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>o</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>L</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='nam'>o</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>L</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>popitem</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>while</span> <span class='num'>1</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>value</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>popitem</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>key</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>o</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>o</span><span class='op'>,</span> <span class='nam'>value</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>pop</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>pop</span><span class='op'>(</span><span class='nam'>ref</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>)</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>setdefault</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>default</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>setdefault</span><span class='op'>(</span><span class='nam'>ref</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_remove</span><span class='op'>)</span><span class='op'>,</span><span class='nam'>default</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>update</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>dict</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>d</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>dict</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>,</span> <span class='str'>&quot;items&quot;</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>dict</span> <span class='op'>=</span> <span class='nam'>type</span><span class='op'>(</span><span class='op'>{</span><span class='op'>}</span><span class='op'>)</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>value</span> <span class='key'>in</span> <span class='nam'>dict</span><span class='op'>.</span><span class='nam'>items</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>d</span><span class='op'>[</span><span class='nam'>ref</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_remove</span><span class='op'>)</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>value</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
    
</td>
</tr>
</table>
</div>

</body>
</html>
